package com.eastfair.venuebooking.service;

import com.eastfair.boot.service.SuperService;
import com.eastfair.venuebooking.dto.FollowPlanDTO;
import com.eastfair.venuebooking.entity.FollowPlan;

import java.time.LocalDateTime;

/**
 * <p>
 * 业务接口
 * 跟进计划表
 * </p>
 *
 * @author linan
 * @date 2022 -06-08
 */
public interface FollowPlanService extends SuperService<FollowPlan> {

    /**
     * 保存跟进计划.
     *
     * @param followPlanDTO the follow plan dto
     * @return the boolean
     */
    boolean saveFollowPlan(FollowPlanDTO followPlanDTO);

    /**
     * 发送站内信提醒.
     *
     * @param followPlan the follow plan dto
     * @return the boolean
     */
    boolean sendRemindInnerMsg(FollowPlan followPlan);

    /**
     * 异步发送站内信.
     *
     * @param followPlan the follow plan
     */
    void asyncSendRemindInnerMsg(FollowPlan followPlan);

    /**
     * 发送短信提醒.
     *
     * @param followPlan the follow plan
     * @return the boolean
     */
    boolean sendRemindSmsMsg(FollowPlan followPlan);

    /**
     * 异步发送短信提醒.
     *
     * @param followPlan the follow plan
     */
    void asyncSendRemindSmsMsg(FollowPlan followPlan);

    /**
     * 获取下次跟进时间.
     *
     * @param planFollowDate the plan follow date
     * @param nextFollowDate the next follow date
     * @return the next follow date
     */
    static LocalDateTime getNextFollowDate(LocalDateTime planFollowDate, LocalDateTime nextFollowDate) {
        if (nextFollowDate == null) {
            return planFollowDate;
        }
        if (planFollowDate == null) {
            return null;
        }
        return nextFollowDate.isBefore(planFollowDate) ? nextFollowDate : planFollowDate;
    }
}
